package com.gx.controller.page;

import com.gx.base.CurrentUser;
import com.gx.core.shiro.utils.ShiroUtils;
import com.gx.domain.SysUser;
import com.gx.service.api.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/user")
public class UserUiPageController {

    @Autowired
    private SysUserService sysUserService;

    @GetMapping("/updateUserDetail.htm")
    public ModelAndView updateUserDetail(Model model) {
        ModelAndView mv = new ModelAndView("/system/user/edit");
        CurrentUser currentUser = ShiroUtils.getCurrentUser();
        SysUser sysUser = sysUserService.queryObject(currentUser.getUserId());
        mv.addObject("model", sysUser);
        return mv;
    }

    @GetMapping("/rePassword.htm")
    public ModelAndView rePassword(Model model) {
        ModelAndView mv = new ModelAndView("/system/user/repassword");
//        CurrentUser currentUser = ShiroUtils.getCurrentUser();
//        SysUser sysUser = sysUserService.queryObject(currentUser.getUserId());
//        mv.addObject("model", sysUser);
        return mv;
    }

    @GetMapping("/userList.htm")
    public String userList() {
        return "/system/user/list";
    }

//    @RequestMapping("/userList.htm")
//    public ModelAndView galleryList() {
//        ModelAndView mv = new ModelAndView();
//        mv.setViewName("/system/user/list");
//        return mv;
//    }
}
